﻿B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Receiver
Version=12.2
@EndOfDesignText@
Sub Process_Globals
	Dim rv As RemoteViews
	Private cls As xlrcls
	Private lastClick As Long=0
End Sub


'Called when an intent is received. 
'Do not assume that anything else, including the starter service, has run before this method.
Private Sub Receiver_Receive (FirstTime As Boolean, StartingIntent As Intent)
	If FirstTime Then
		rv=ConfigureHomeWidget("layrv","rv",60,"当前时课",True)
		cls.Initialize
		Dim txt As String=cls.calcSimple
		rv.SetText("lblrv",txt)
	Else
		cls.Initialize2(cls.CurrentDate)
	End If
	
	If StartingIntent.HasExtra("b4a_internal_event") Then
		Dim evt As String=StartingIntent.GetExtra("b4a_internal_event")
		If evt=="lblrv_click" Then
			lblrv_Click
		End If
	End If
	rv.UpdateWidget
End Sub
Sub lblrv_Click
	If DateTime.Now-lastClick<10000 Then
		'两次点击间隔小于10秒则启动界面
		lastClick=DateTime.Now
		StartActivity(Main)
	Else
		lastClick=DateTime.Now
		ToastMessageShow("正在重新计算",False)
		cls.Initialize2(cls.CurrentDate)
		Dim txt As String=cls.calcSimple
		rv.SetText("lblrv",txt)
		Sleep(0)
		rv.UpdateWidget
	End If
End Sub
Sub rv_RequestUpdate
	Log("rv_RequestUpdate")
	cls.Initialize2(cls.CurrentDate)
	Dim txt As String=cls.calcSimple
	rv.SetText("lblrv",txt)
	rv.UpdateWidget
End Sub